<template>
	<view>
		<view class="list">
			<view class="li">
				<view>
					旧密码：
				</view>
				<u--input color="#959595" v-model="password" placeholder="请入密码"></u--input>
			</view>
			<view class="hr"></view>
			<view class="li">
				<view>
					新密码：
				</view>
				<u--input class="li" color="#959595" v-model="newPassword" placeholder="请入新密码"></u--input>
			</view>
			<view class="hr"></view>
			<view class="li">
				<view>
					请再输入：
				</view>
				<u--input class="li" color="#959595" v-model="newPasswordAgain" placeholder="请入再次新密码"></u--input>
			</view>
		</view>
		
		<u-toast ref="uToast"></u-toast>
		<view class="but" @click="changePwd()">确定修改</view>
	</view>
</template>

<script>
	import {apiupdateLoginPass} from '@/api/app.js'
	export default {
		data() {
			return {
				newPasswordAgain:"",
				newPassword:"",
				password:"",
				// newuserTel: "",
				userTel: '',
				determineid: null,
				tips: '',
				// refCode: null,
				seconds: 120,
				value5: '',
				codeshow: false,
				code:''

			}
		},
		methods: {
			// 修改密码
			changePwd(){
				let userId= uni.getStorageSync("userId")
				if(this.password==""){
					this.$refs.uToast.show({
						duration: 2000,
						message: '新密码不能为空'
					})
					return;
				}
				if (this.newPassword == "") {
					this.$refs.uToast.show({
						duration: 2000,
						message: '旧密码不能为空'
					})
					return;
				}
				if (this.newPasswordAgain== "") {
					this.$refs.uToast.show({
						duration: 2000,
						message: '旧密码不能为空'
					})
					return;
				}
				let params={
					password:this.password,
					newPassword:this.newPassword,
					newPasswordAgain:this.newPasswordAgain,
					id:userId
				}
				apiupdateLoginPass(params).then(res=>{
					console.log(res)
					if(res.code==200){
						uni.showToast({
						 title: '修改成功',
						 icon: 'none'
						})
						setTimeout( () => {
						    uni.reLaunch({
						    	url: '/pages/login/login'
						    })		
						}, 1000)
					}
				})
			},

		},
		onLoad() {
		}
	}
</script>

<style scoped lang="scss">
	.list {

		background-color: #fff;
		padding: 0rpx 20rpx;

		.li {
			height: 80rpx;
			line-height: 80rpx;
			display: flex;
		}

		.code {
			margin: 20rpx 0rpx;
			color: #55aaff;
		}

		.codetext {
			padding-bottom: 30rpx;
		}

		.hr {
			margin: 10rpx 0rpx;
			border-bottom: #c7c7c7 solid 2rpx;
		}
	}

	.but {
		margin: 130rpx auto;
		width: 700rpx;
		height: 80rpx;
		border-radius: 50rpx;
		color: #000000;
		text-align: center;
		line-height: 80rpx;
		font-weight: 600;
		background-color: $theme-color;
	}
</style>